<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@include file="../common/jspcommon.jsp" %>
<script type="text/javascript">

	function minusOne(){
		var obj=$("#rnums");
		var n=parseInt(obj.val());
		if(n-1>0){
			obj.val(n-1);
		}
		
	}
	
	function addOne(){
		var obj=$("#rnums");
		var n=parseInt(obj.val());
		$.post("roomNum.htm",{roomId:"${room.id}"},function(num){
			if(num<n+1){
				alert("库存不足");
			}else{
				obj.val(n+1);
			}
		});
		
	}
	$(function(){
		$("#bookRoomForm").validate({
			rules : {
				ldate :{required : true},
				member:{required : true}
			},
			messages : {
				ldate : {required : "填写离店日期"},
				member:{required:"请登录"}
			}
		});
	});
</script>
<div class="tc_wrap">
    	<a href="javascript:void(0)" class="btn_close">关闭</a>
        <div class="tc_infobox">
            <form action="tobuyr.htm" id="bookRoomForm" method="post">
				<div class="tc_hotel_wrap">
				  <p>您选择的入住日期:<span class="date">${roomPrice.spDate }</span></p>
	              <p>请选择离店日期:
	              	<input name="ldate" id="ldate" type="text" class="Wdate" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'${minDate }',maxDate:'${maxDate }',readOnly:true,highLineWeekDay:true,isShowOthers:true});"/> 
	              	<!-- 住:<i class="clrf60 mr5 ml5">0</i>晚 -->
	              </p>
	              <p>请选择房间数:</p>
	              <p class="room_info">
	              		<i>${room.name }</i>&nbsp;&nbsp;&nbsp;(<i class="clrf60">¥${roomPrice.priceA }</i>)<br>
	                    <a href="javascript:void(0)" class="minus" onclick="minusOne();">减</a>
	                    <input name="count" class="nums" value="1" id="rnums" readonly="readonly"/>
	                    <a href="javascript:void(0)" class="add" onclick="addOne();">加</a> &nbsp;间/夜
	              </p>
	              <p>
	              	<input type="submit"  id="nextBtn" value="" class="next" style="cursor: pointer;"/>
	              	<input type="hidden" name="member" value="${onlineUser.member }"/>
	              </p>
	            </div>
	            <input type="hidden" name="rid" id="rid" value="${room.id }"/>
      		    <input type="hidden" name=udate id="udate" value="${roomPrice.spDate }"/>
           </form>
        </div>
</div>
